package org.mindrive.system.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
/**
 * 字节流转字符串
 * 
 */
public class InputStream2Str {
	 public static String Inputstr2Str_Reader(InputStream in, String encode)
	    {
	        
	        String str = "";
	        try
	        {
	            if (encode == null || encode.equals(""))
	            {
	                // 默认以utf-8形式
	                encode = "utf-8";
	            }
	            BufferedReader reader = new BufferedReader(new InputStreamReader(in, encode));
	            StringBuffer sb = new StringBuffer();
	            
	            try {
					while ((str = reader.readLine()) != null)
					{
					    sb.append(str).append("\n");
					}
				} catch (java.io.IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
	            return sb.toString();
	        }
	        catch (UnsupportedEncodingException e1)
	        {
	            e1.printStackTrace();
	        }
	        catch (IOException e)
	        {
	            e.printStackTrace();
	        }
	        
	        return str;
	    }
}
